#!/usr/bin/env bash
# Copyright (c) 2020 The Toltec Contributors
# SPDX-License-Identifier: MIT

pkgnames=(tailscale-systemd)
pkgdesc="SystemD configuration for tailscale"
url=https://tailscale.com
pkgver=0.0.0-2
section="utils"
timestamp=2023-07-12T00:00Z
maintainer="Kai <z@kwi.li>"
license="BSD 3-Clause"
installdepends=(tailscale)

source=(
    tailscaled.service
)
sha256sums=(
    SKIP
)

package() {
    install -D -m 644 -t "$pkgdir"/etc/systemd/system "$srcdir"/tailscaled.service
}

configure() {
    systemctl daemon-reload
    systemctl enable tailscaled
    systemctl start tailscaled
}

preremove() {
    disable-unit "tailscaled.service"
}

postremove() {
    systemctl daemon-reload
}
